//
//  YFBaseViewController.m
//  SquashSpark
//
//  Created by Coollang on 2017/10/26.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "YFBaseViewController.h"
#import "JCClubApi.h"
#import "SQActionSheetView.h"

@interface YFBaseViewController ()

@end

@implementation YFBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
   
}

- (NSAttributedString *)creatAttributedString:(NSString *)contentString
                                         font:(UIFont *)font
                                        color:(UIColor *)color{
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = font;
    attrs[NSForegroundColorAttributeName] = color;
    NSAttributedString *attStr = [[NSAttributedString alloc] initWithString:contentString attributes:attrs];
    return attStr;
}

- (void)baseUI {
    self.view.backgroundColor = kNavBgThemeColor;
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
-(UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
    return UIStatusBarAnimationSlide;
}
- (BOOL)prefersStatusBarHidden {
    return NO;
}


//是否自动旋转,返回YES可以自动旋转,返回NO禁止旋转
- (BOOL)shouldAutorotate{
    return NO;
}
//返回支持的方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}
//由模态推出的视图控制器 优先支持的屏幕方向
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationPortrait;
}

- (WSProgressHUD *)hud{
    if (_hud == nil) {
        _hud = [WSProgressHUD showOnView:self.view andString:@""];
        [_hud showWithMaskType:WSProgressHUDMaskTypeGradient];
        [_hud dismiss];
    }
    return _hud;
}

//举报动作
- (void)reportAction:(NSString *)reportID spotterIDType:(SpotterIDType) spotterIDType{
    __weak typeof(self)weakSelf = self;
    NSArray *buttonStrs = @[@"I don't like it",
                            @"It is spam",
                            @"It contains sensitive information",
                            @"It is insulting and harmful",
                            @"Cancel"];
    NSArray *colors = @[[UIColor blackColor],[UIColor blackColor],[UIColor blackColor],[UIColor blackColor],[UIColor blackColor],[UIColor blackColor]];
    SQActionSheetView *reportSheet = [[SQActionSheetView alloc]initWithTitle:@"Select the reason for report" buttons:buttonStrs colors:colors buttonClick:^(SQActionSheetView *sheetView, NSInteger buttonIndex) {
        if (buttonIndex < 4) {
            [weakSelf spotterAction:buttonIndex+1 spotterID:reportID spotterIDType:spotterIDType];
        }
    }];
    [reportSheet showView];
}

- (void)spotterAction:(SpotterTopicType)spotterType
            spotterID:(NSString *)spotterID
        spotterIDType:(SpotterIDType) spotterIDType{
    __weak typeof(self) weakSelf = self;
    [JCClubApi spotterWithID:spotterID spotterIDType:spotterIDType spotterType:spotterType complete:^(NSError *error) {
        if (error) {
            [weakSelf.hud showErrorWithString:error.domain dimissAfterSecond:2];
        }else{
            [weakSelf.hud showSuccessWithStatus:@"Thanks!" dimissAfterSecond:2];
        }
    }];
}

@end
